#include "mainwindow.h"
#include <QDockWidget>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), textEdit(new QTextEdit)
{
    // 中间的主窗口设置为文本编辑器
    setCentralWidget(textEdit);

    // 添加将关闭的子窗口重新调出来的菜单
    createActions();
}

MainWindow::~MainWindow()
{
}

void MainWindow::createActions()
{
    // 创建菜单栏和新建可拖动贴靠、关闭、重新打开的子窗口
    viewMenu = menuBar()->addMenu(tr("&View"));
    QDockWidget *dock = new QDockWidget(tr("Customers"), this);
    addDockWidget(Qt::LeftDockWidgetArea, dock);
    viewMenu->addAction(dock->toggleViewAction());
    dock = new QDockWidget(tr("Paragraphs"), this);
    addDockWidget(Qt::RightDockWidgetArea, dock);
    viewMenu->addAction(dock->toggleViewAction());
}
